package com.liwalo.dao;

// Generated 24-ago-2013 14:46:30 by Hibernate Tools 3.6.0
import static org.hibernate.criterion.Example.create;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.SessionFactory;

import com.liwalo.entities.Confirmaciones;
import com.liwalo.utils.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 * Home object for domain model class Confirmaciones.
 *
 * @see com.liwalo.dao.Confirmaciones
 * @author Hibernate Tools
 */
public class ConfirmacionesDAO {

    private final SessionFactory sessionFactory = HibernateUtil.getSessionFactory();

    public void persist(Confirmaciones transientInstance) {
        Session session = sessionFactory.getCurrentSession();
        Transaction tx = session.beginTransaction();
        try {
            session.persist(transientInstance);
            tx.commit();
        } catch (RuntimeException re) {
            tx.rollback();
            throw re;
        }
    }

    public void update(Confirmaciones instance) {
        Session session = sessionFactory.getCurrentSession();
        Transaction tx = session.beginTransaction();
        try {
            session.saveOrUpdate(instance);
            tx.commit();
        } catch (RuntimeException re) {
            tx.rollback();
            throw re;
        }
    }

    public void attachClean(Confirmaciones instance) {
        Session session = sessionFactory.getCurrentSession();
        Transaction tx = session.beginTransaction();
        try {
            session.lock(instance, LockMode.NONE);
            tx.commit();
        } catch (RuntimeException re) {
            tx.rollback();
            throw re;
        }
    }

    public void delete(Confirmaciones persistentInstance) {
        Session session = sessionFactory.getCurrentSession();
        Transaction tx = session.beginTransaction();
        try {
            session.delete(persistentInstance);
            tx.commit();
        } catch (RuntimeException re) {
            tx.rollback();
            throw re;
        }
    }

    public Confirmaciones merge(Confirmaciones detachedInstance) {
        Session session = sessionFactory.getCurrentSession();
        Transaction tx = session.beginTransaction();
        try {
            Confirmaciones result = (Confirmaciones) session.merge(detachedInstance);
            tx.commit();
            return result;
        } catch (RuntimeException re) {
            tx.rollback();
            throw re;
        }
    }

    public Confirmaciones findById(java.lang.Integer id) {
        Session session = sessionFactory.getCurrentSession();
        try {
            session.beginTransaction();
            Confirmaciones instance = (Confirmaciones) session.get(Confirmaciones.class, id);
            return instance;
        } catch (RuntimeException re) {
            throw re;
        }
    }

    public List<Confirmaciones> findByExample(Confirmaciones instance) {
        Session session = sessionFactory.getCurrentSession();
        try {
            session.beginTransaction();
            List<Confirmaciones> results = (List<Confirmaciones>) session
                    .createCriteria("com.liwalo.dao.Confirmaciones")
                    .add(create(instance)).list();
            return results;
        } catch (RuntimeException re) {
            throw re;
        }
    }
}
